package com.ruoyi.common.core.domain;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.core.domain.entity.*;

/**
 * Treeselect树结构实体类
 *
 * @author ruoyi
 */
public class TreeSelect implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 节点ID
     */
    private String id;

    /**
     * 节点名称
     */
    private String label;

    private String code;

    private Boolean user;

    private String parentId;

    private String parentname;
    /**
     * 子节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelect> children;

    private Map<String,Object> params;

    public TreeSelect() {

    }

    public TreeSelect(SysDept dept) {
        this.id = dept.getId().toString();
        this.label = dept.getName();
        this.code = dept.getCode();
        this.user = dept.getUser();
        this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
        this.parentname=dept.getParentname();
    }

    public TreeSelect(SysMenu menu) {
        this.id = menu.getMenuId().toString();
        this.label = menu.getMenuName();
        this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(TRiskCategory cg) {
        this.id = cg.getId();
        this.label = cg.getCaption();
        this.children = cg.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(TContractorSafetycheckCategory cg) {
        this.id = cg.getId();
        this.label = cg.getCaption();
        this.children = cg.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(TRiskLibraryCategory cg) {
        this.id = cg.getId();
        this.label = cg.getCaption();
        this.children = cg.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(TBasicRegion rg) {
        this.id = rg.getId().toString();
        this.label = rg.getName();
        this.children = rg.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(TTrainCoursekind ck) {
        this.id = ck.getId().toString();
        this.label = ck.getName();
        this.code = ck.getCode();
        this.children = ck.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(TSafetyanalysisObject t) {
        this.id = t.getId().toString();
        this.label = t.getName();
        this.code=t.getCode();
        this.children = t.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(TSafetymanageCategory t) {
        this.id = t.getId().toString();
        this.label = t.getCaption();
        this.code=t.getCode();
        this.children = t.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(TRiskBasisCheckobject t){
        Map<String,Object> params=new HashMap<>();
        params.put("logo",t.getLogo());

        this.id=t.getId().toString();
        this.label=t.getCname();
        this.code=t.getCno();
        this.children=t.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
        this.params=params;
    }

    public TreeSelect(TEquipmentProjectdatamanagekind pk) {
        this.id = pk.getId().toString();
        this.label = pk.getName();
        this.code = pk.getCode();
        this.children = pk.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(TProcesssafetyInformationcategory ic) {
        this.id = ic.getId().toString();
        this.label = ic.getName();
        this.code = ic.getCode();
        this.children = ic.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Boolean getUser() {
        return user;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getParentname() {
        return parentname;
    }

    public void setParentname(String parentname) {
        this.parentname = parentname;
    }

    public void setUser(Boolean user) {
        this.user = user;
    }

    public List<TreeSelect> getChildren() {
        return children;
    }

    public void setChildren(List<TreeSelect> children) {
        this.children = children;
    }

    public Map<String, Object> getParams() {
        return params;
    }

    public void setParams(Map<String, Object> params) {
        this.params = params;
    }
}
